package com.jframe.sys.controller.utils;

import javax.servlet.http.HttpServletRequest;

import com.jframe.sys.utils.SpringUtil;


public class SysService {
	
	/**
	 * Spring 服务定位
	 * @param name
	 * @return
	 */
	public  Object getBean(String name){
		 return SpringUtil.getBean(name);		
	}
	/**
	 * 获取当前登录用户对象
	 * @param request
	 * @return
	 */
	public  Object getCurUser(HttpServletRequest request){
		return request.getSession().getAttribute("curUser");
	}
	
	/**
	 * 获取页面请求参数
	 * @param request
	 * @return 返回Param ,通过调用param方法可以获取各页面请求参数
	 */
	public  Param  getParam(HttpServletRequest request)
	{
		return new Param( request.getParameterMap());
	}
	/**
	 * 获取根目录地址
	 * @param request
	 * @return
	 */
	public  String getRealPath(HttpServletRequest request)
	  {
		  return request.getRealPath("/");
	  }
	  /**
	   * 获取用户主机ip
	   * @param request
	   * @return
	   */
	  public  String getUserIp(HttpServletRequest request)
	  {
		  return request.getRemoteAddr();
	  }
	  /**
	   * 获取用户主机名
	   * @param request
	   * @return
	   */
	  public  String getUserHost(HttpServletRequest request)
	  {
		  return request.getRemoteHost();
	  }

}
